package org.marsdonne.auth.wechat;

import org.marsdonne.auth.BindRequest;

import java.util.Map;

public interface WechatAuthApi {
    String API_WECHAT_BASEURL = "https://api.weixin.qq.com";
    String API_USER_INFO_URL = API_WECHAT_BASEURL + "/cgi-bin/user/info?access_token={access_token}&openid={openid}&lang=zh_CN";
    String API_CODE2SESSION_URL = API_WECHAT_BASEURL + "/sns/jscode2session?grant_type=authorization_code&appid={appId}&secret={secret}&js_code={js_code}";
    String API_GET_WXA_CODE_URL = API_WECHAT_BASEURL + "/wxa/getwxacodeunlimit?access_token={access_token}";

    enum Resp4Err {
        RESPONSE_ERR_MSG("errmsg"), RESPONSE_ERR_CODE("errcode");
        public final String value;

        Resp4Err(String value) {
            this.value = value;
        }
    }

    enum ErrCode {
        Busy(-1), Success(0), InvalidCode(40029), FrequencyLimited(45011);
        public Integer value;

        ErrCode(Integer value) {
            this.value = value;
        }
    }

    enum Resp4Code2Session {
        SessionKey("session_key"), OpenID("openid"), UnionID("unionid");
        public final String value;

        Resp4Code2Session(String value) {
            this.value = value;
        }
    }

    enum Resp4UserInfo {
        Subscribe("subscribe"), OpenID("openid"), UnionID("unionid");
        public final String value;

        Resp4UserInfo(String value) {
            this.value = value;
        }
    }

    Map code2session(BindRequest bindRequest);

    Map getUserInfo(String token, String openid);

    byte[] getQrCode(QrCodeRequest request);
}
